/** 
 *  @file
 *  @brief   圆管2（TUBE2）梁截面属性使用解析公式计算类
 *  @author  yuanchenxi
 *  @date    2024.04.16
 *  @version v1.0
 *  @par Copyright(c):  ShenGong  Simulation corporation
 */

#include "Tube2SectionFormulaCalculator.h"
#include "DataStructure/Common/Real.h"
#include "TubeSectionFormulaCalculator.h"

using SG::DataStructure::Common::Real;
using SG::DataStructure::FEM::PBARLData;
using SG::DataStructure::FEM::PBARData;
using SG::FEMSolver::Element::TubeSectionFormulaCalculator;
using SG::FEMSolver::Element::Tube2SectionFormulaCalculator;

void Tube2SectionFormulaCalculator::Compute
(
const SG::DataStructure::FEM::PBARLData& section,
_OUT SG::DataStructure::FEM::PBARData&   property,
_OUT SG::Algebra::Point&                 centroid
) const
{
    /* NASTRAN 的 TUBE2 形梁截面转换成 TUBE 形梁截面
     * 
     * tube.dim1 = tube2.dim1
     * tube.dim2 = tube2.dim1 - tube2.dim2
     * 详细请参考 NASTRAN 手册
     */
    Real ro{section.m_dimension.at(0)};
    Real ri{ro - section.m_dimension.at(1)};
    PBARLData tubeSection{section};
    tubeSection.m_dimension = {ro, ri};

    TubeSectionFormulaCalculator tubeCalculator;
    tubeCalculator.Compute (tubeSection, _OUT property, _OUT centroid);
}